home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Translation Manager / Sample Code / Translation Extension Example / TranslationComponent.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-05  |  5.6 KB  |  144 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        TranslationComponent.h
  3.  
  4.     Contains:    Header file for a translation extension component
  5.     
  6.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  7. */
  8.  
  9. #ifndef __TRANSLATIONCOMPONENT__
  10. #define __TRANSLATIONCOMPONENT__
  11.  
  12. #ifndef __TRANSLATIONEXTENSIONS__
  13. #include <TranslationExtensions.h>
  14. #endif
  15.  
  16. // Function prototypes
  17.  
  18. pascal ComponentResult DoGetFileTranslationList(
  19.                                         ComponentInstance    self,
  20.                                         FileTranslationListHandle translationList);
  21.                                                 
  22. pascal ComponentResult DoIdentifyFile(    ComponentInstance     self,
  23.                                         const FSSpec*         theDoc,
  24.                                         FileType*             docKind    );
  25.                                                 
  26. pascal ComponentResult DoTranslateFile(    ComponentInstance    self,
  27.                                         TranslationRefNum    progressRefNum,
  28.                                         const                 FSSpec* srcDoc,
  29.                                         FileType            srcType,
  30.                                         long                 srcTypeHint, 
  31.                                         const FSSpec*         dstDoc, 
  32.                                         FileType            dstType, 
  33.                                         long                 dstTypeHint    );
  34.                                         
  35. pascal ComponentResult DoGetScrapTranslationList(
  36.                                         ComponentInstance    self,
  37.                                         ScrapTranslationListHandle list    );
  38.  
  39. pascal ComponentResult DoIdentifyScrap(    ComponentInstance    self,
  40.                                         const void*         dataPtr,
  41.                                         Size                dataLength,
  42.                                         ScrapType*            dataFormat    );
  43.  
  44. pascal ComponentResult DoTranslateScrap(ComponentInstance     self,
  45.                                         TranslationRefNum    progressRefNum,
  46.                                         const void*         srcDataPtr, 
  47.                                         Size                srcDataLength,
  48.                                         ScrapType             srcType,
  49.                                         long                 srcTypeHint,
  50.                                         Handle                dstData,
  51.                                         ScrapType            dstType,
  52.                                         long                 dstTypeHint    );
  53.                                         
  54. pascal ComponentResult DoGetTranslatedFilename(
  55.                                         ComponentInstance     self,
  56.                                         FileType            dstType,
  57.                                         long                dstTypeHint,
  58.                                         FSSpec*             theDocument    );
  59.  
  60. #ifdef powerc                                   
  61.  
  62. // Universal ProcPtr info
  63.                                
  64. enum {    
  65.     uppDoGetFileTranslationListProcInfo = kPascalStackBased
  66.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  67.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  68.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FileTranslationListHandle))),
  69.         
  70.     uppDoIdentifyFileProcInfo = kPascalStackBased
  71.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  72.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  73.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FSSpec*)))
  74.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(FileType*))),
  75.     
  76.     uppDoTranslateFileProcInfo = kPascalStackBased
  77.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  78.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  79.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(TranslationRefNum)))
  80.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(FSSpec*)))
  81.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(FileType)))
  82.         | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  83.         | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(FSSpec*)))
  84.         | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(FileType)))  
  85.         | STACK_ROUTINE_PARAMETER(8, SIZE_CODE(sizeof(long))),
  86.        
  87.       uppDoGetScrapTranslationListProcInfo = kPascalStackBased
  88.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  89.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  90.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ScrapTranslationListHandle))),
  91.         
  92.       uppDoIdentifyScrapProcInfo = kPascalStackBased
  93.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  94.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  95.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void*)))
  96.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Size))) 
  97.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(ScrapType*))),
  98.  
  99.       uppDoTranslateScrapProcInfo = kPascalStackBased
  100.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  101.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  102.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(TranslationRefNum))) 
  103.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*))) 
  104.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Size))) 
  105.         | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(ScrapType))) 
  106.         | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long))) 
  107.         | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(Handle))) 
  108.         | STACK_ROUTINE_PARAMETER(8, SIZE_CODE(sizeof(ScrapType))) 
  109.         | STACK_ROUTINE_PARAMETER(9, SIZE_CODE(sizeof(long))),
  110.         
  111.       uppDoGetTranslatedFilenameProcInfo = kPascalStackBased
  112.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  113.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentInstance))) 
  114.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FileType)))
  115.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) 
  116.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(FSSpec* )))
  117.         
  118.      };
  119.     
  120. #endif
  121.  
  122. // CallComponent macros for PowerPC and 68K                               
  123.  
  124. #ifdef powerc    
  125.  
  126.     #define CallComponentFunctionWithStorageUniv(storage, params, funcName)        \
  127.                          CallComponentFunctionWithStorage(storage, params, &funcName##RD)    
  128.                         
  129.     #define CallComponentFunctionUniv(params, funcName)    \
  130.                         CallComponentFunction(params, &funcName##RD)
  131.                         
  132.     #define INSTANTIATE_ROUTINE_DESCRIPTOR(funcName)    \
  133.                         RoutineDescriptor funcName##RD = BUILD_ROUTINE_DESCRIPTOR (upp##funcName##ProcInfo, funcName)
  134.                         
  135. #else
  136.     #define CallComponentFunctionWithStorageUniv(storage, params, funcName)        \
  137.                         CallComponentFunctionWithStorage(storage, params, (ComponentFunctionUPP)funcName) 
  138.                         
  139.     #define CallComponentFunctionUniv(params, funcName)    \
  140.                         CallComponentFunction(params, (ComponentFunctionUPP)funcName)
  141. #endif
  142.  
  143. #endif // __TRANSLATIONCOMPONENT__
  144.